package com.zjcode.oa;

import com.chinatechstar.component.commons.utils.UuidUtil;
import com.zjcode.oa.model.OaProjectJournal;
import com.zjcode.oa.service.ProjectJournalService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;

/**
 * @ClassName:ZjcodeOAServiceApplication
 * @功能：
 * @author：wlei
 * @日期：2022/4/8-2:52 PM
 **/
@SpringBootApplication(scanBasePackages = "com.zjcode.oa")
@EnableDiscoveryClient
@EnableOAuth2Client
@EnableFeignClients(basePackages = {"com.zjcode.oa"})
@EnableCircuitBreaker
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Slf4j
public class ZjcodeOAServiceApplication implements CommandLineRunner {

    @Autowired
    private ProjectJournalService projectJournalService;

    public static void main(String[] args) {
        log.info("启动oa管理服务开始");
        SpringApplication.run(ZjcodeOAServiceApplication.class, args);
        log.info("启动oa管理服务完成");
    }

    @Override
    public void run(String... args) throws Exception {
        // 插入测试数据
        //List<OaProjectJournal> list = new ArrayList<>();
        //for (int i = 0; i < 100; i++) {
        //    OaProjectJournal journal = new OaProjectJournal();
        //    journal.setId(UuidUtil.get32UUID());
        //    journal.setProjectId("1");
        //    journal.setRecordDatetime(new Date(System.currentTimeMillis()));
        //    journal.setRemarks("开发项目日志模块_测试_" + i);
        //    journal.setCreateBy("962057298671112192");
        //    journal.setCreateTime(new Date(System.currentTimeMillis()));
        //    journal.setUpdateTime(new Date(System.currentTimeMillis()));
        //    journal.setIsDelete(0);
        //    list.add(journal);
        //}
        //
        //for (int i = 0; i < 100; i++) {
        //    OaProjectJournal journal = new OaProjectJournal();
        //    journal.setId(UuidUtil.get32UUID());
        //    journal.setProjectId("1");
        //    journal.setRecordDatetime(new Date(System.currentTimeMillis()));
        //    journal.setRemarks("开发项目日志模块_测试_2_" + i);
        //    journal.setCreateBy("653917974152592329");
        //    journal.setCreateTime(new Date(System.currentTimeMillis()));
        //    journal.setUpdateTime(new Date(System.currentTimeMillis()));
        //    journal.setIsDelete(0);
        //    list.add(journal);
        //}
        //projectJournalService.insertList(list);
    }
}
